package com.nickstumpos.android.GmailWidgetPlus.Configure.OptionsList.options;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.ListView;

import com.nickstumpos.android.GmailWidgetPlus.R;
import com.nickstumpos.android.GmailWidgetPlus.Configure.OptionsList.OptionsList;
import com.nickstumpos.android.GmailWidgetPlus.Constants.GMWP_Constants;

public final class ShowAllOptionList extends OptionsList {

	private final static int	showall_pos	= 1;

	public ShowAllOptionList(final Context context,
			final int widgetId,
			final String title) {

		super(context, widgetId, title);
	}

	@Override
	protected void save() {

		final SharedPreferences.Editor prefs = this.getPrefs().edit();
		prefs.putBoolean(GMWP_Constants.PREF_SHOWALL_REF + this.getWidgetId(),
				this.getCheckedItemPosition() == ShowAllOptionList.showall_pos ? true
						: false);
		prefs.commit();
	}

	@Override
	protected void setupDialog() {

		this.getAa().add(this.getContext().getString(R.string.show_all_labels));
		this.getAa().add(this.getContext()
				.getString(R.string.show_only_labels_with_unread_messages));
		this.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
		if (this.getPrefs()
				.getBoolean(GMWP_Constants.PREF_SHOWALL_REF + this.getWidgetId(),
						false)) {
			this.setItemChecked(1, true);
		} else {
			this.setItemChecked(2, true);
		}
	}
}
